<?php

namespace App\Model;

//use Illuminate\Database\Eloquent\Model;

class RolePermission extends Model
{
    public $dates = ['deleted_at'];


    // 允许显示的字段
    protected $fillable = ['id','role','permission','admin_id','created_at','updated_at'];

    static public function _validate(){
        return array(
            'role'=>'max:10',
            'permission'=>'max:10',
            'admin_id'=>'max:10',
        );
    }

    static public function RPcreate($data){
        $data = self::validate($data);
        if(!isset($data['status']) ||!$data['status']){
            return $data;
        }
        $RP = self::create($data['data']);
        if(!isset($RP->id)){
            return Json::error('添加出错');
        }
        return Json::success($RP);
    }
}
